package com.itheima.leetcode.od.c.bf;

import java.util.Scanner;

/**
 * <h3>有效子字符串（子序列）</h3>
 */
public class IsSubsequence {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String s = scanner.next();
        String t = scanner.next();
        isSubsequence(s, t);
    }

    public static int isSubsequence(String s, String t) {
        int n = s.length();
        int m = t.length();
        int i = 0;
        int j = 0;
        int ans = 0;
        while (i < n && j < m) {
            if (s.charAt(i) == t.charAt(j)) {
                ans = j;
                i++;
            }
            j++;
        }
        return ans;
    }
}